import directive from '@/directive';
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import { router } from '@routers/router';
import { useApi } from '@utils/api';
import { ICache, cache } from '@utils/cache';
import { IHttp } from '@utils/http';
import dayjs from 'dayjs';
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
import localizedFormat from 'dayjs/plugin/localizedFormat';
import timezone from 'dayjs/plugin/timezone';
import utc from 'dayjs/plugin/utc';
import weekday from 'dayjs/plugin/weekday';
import ElementPlus from 'element-plus';
import { createPinia } from 'pinia';
import { createApp } from 'vue';
import Boot from './boot.vue';
import './style.scss';
import JsonViewer from "vue3-json-viewer";
import "vue3-json-viewer/dist/index.css"; // 引入样式
dayjs.extend(localizedFormat);
dayjs.extend(isSameOrAfter);
dayjs.extend(isSameOrBefore);
dayjs.extend(weekday);
dayjs.locale('en');
dayjs.extend(timezone);
dayjs.extend(utc);
dayjs.extend(weekday);
dayjs.tz.setDefault('America/Los_Angeles');

const pinia = createPinia();
const app = createApp(Boot);

app.provide<IHttp>('api', useApi());
app.provide<ICache>('cache', cache);
app.use(JsonViewer);
app.use(directive);
app.use(pinia);
app.use(router);
app.use(ElementPlus);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

app.mount('#app-root');
